package cc.rengu.igas.channel.wechat.core.service.trans;

import cc.rengu.igas.channel.wechat.common.enums.RespCodeEnum;
import cc.rengu.igas.channel.wechat.core.model.request.WechatMsgManageNoticeRequest;
import cc.rengu.oltp.service.base.BizBaseService;
import cc.rengu.oltp.service.common.constant.AppParamConstant;
import cc.rengu.oltp.service.model.RiskMonitorInfo;
import cc.rengu.oltp.service.model.BizResponse;
import cc.rengu.oltp.utility.annotation.BIZ_PROCESS;
import cc.rengu.oltp.utility.util.ConvertUtil;
import com.alibaba.fastjson.JSON;

/**
 * 微信消息管理通知服务
 * Created by 王成 on 2018/7/26.
 */
public class WechatMsgManageNoticeService extends BizBaseService {
    @Override
    protected Object beforeBizProcess() throws Exception {
        WechatMsgManageNoticeRequest wechatMsgManageNoticeRequest = new WechatMsgManageNoticeRequest();
        ConvertUtil.convertOutput(wechatMsgManageNoticeRequest);
        return wechatMsgManageNoticeRequest;
    }

    @Override
    protected BizResponse callBizService(Object request) throws Exception {
        WechatMsgManageNoticeRequest wechatMsgManageNoticeRequest = (WechatMsgManageNoticeRequest) request;
        rglog.info("消息推送结果通知为:<{}>", JSON.toJSONString(wechatMsgManageNoticeRequest));

        /* 查找BIZ_PROCESS的注解，基于注解实现不同场景的业务逻辑 */
        invokeBizAnnoMethod(BIZ_PROCESS.class);

        BizResponse bizResponse = new BizResponse();
        bizResponse.setRspSysId(AppParamConstant.IGAS);
        bizResponse.setRespCode(RespCodeEnum.TRANS_SUCCESS.getRespCode());
        bizResponse.setRespDesc(RespCodeEnum.TRANS_SUCCESS.getRespDesc());
        return bizResponse;
    }

    @Override
    protected void afterBizProcess(BizResponse response) throws Exception {

    }

    @Override
    protected RiskMonitorInfo getRiskMonitorInfo() {
        return null;
    }
}
